Conversation
cc. @sobolevn |
sobolevn
left a comment
There was a problem hiding this comment.
Please, add tests cases for:
- Empty replace
- Replace with correct value
- Replace with incorrect values
|
|
||
| def __replace__(self, **changes: Any) -> 'BaseContainer': | ||
| """Create a new instance with specified changes.""" | ||
| if set(changes.keys()) - set(self.__slots__): |
There was a problem hiding this comment.
I think that we can simplify this to only allow _inner_value change. Nothing else.
| # backward compatibility with 0.19.0 and earlier | ||
| object.__setattr__(self, '_inner_value', state) # noqa: WPS609 | ||
|
|
||
| def __replace__(self, **changes: Any) -> 'BaseContainer': |
There was a problem hiding this comment.
Ok, I was wrong about adding this method to BaseContainer base class. I think that we need to add this to Unwrappable (?) instead. Basically, right now - this is not type-safe at all.
And add a proper type annotations. And add type tests for it.
I have made things!
Checklist
CHANGELOG.mdRelated issues
fix: #1920
🙏 Please, if you or your company finds
dry-pythonvaluable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.